Option Explicit

Private Const MAX_PATH = 255

Private Declare Function GetSystemDirectory Lib "kernel32" _
Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long


Public Function PrintWebPage(ByVal URL As String) As Boolean
' #VBIDEUtils#*******************************************
' * Programmer: Leo Koach
' * Web Site  : http://www.vbonly.com
' * E-Mail    :
' * Date      : 8/7/2000
' *********************************************************
' * Comments  : Prints web page specified by URL
' *           : Returns True if successful, false otherwise
' *           : Requires IE4 or above
' *           : Will show print dialog before printing
' *           : Example: PrintWebPage "http://www.freevbcode.com"
' *********************************************************
Dim sFile As String
sFile = SystemDir & "\MSHTML.DLL"

'check if .dll to print page exists
If Dir(sFile) = "" Then Exit Function
On Error Resume Next
Shell "rundll32.exe " & sFile & ",PrintHTML " & URL, _
   vbNormalFocus

'return true if no errors
PrintWebPage = Err.Number = 0
End Function

Private Function SystemDir() As String

    Dim sRet As String, lngRet As Long
  
    sRet = String$(MAX_PATH, 0)
    lngRet = GetSystemDirectory(sRet, MAX_PATH)
    SystemDir = Left(sRet, lngRet)

End Function